mudbox::MeshRenderer Class Reference

#include <renderer.h>

Inheritance diagram for mudbox::MeshRenderer:

Inheritance graph
[legend]
List of all members.

Detailed Description

This is the base class for a renderer implementation, which transforms a mesh into the opengl pipeline.

Every mesh has one or more renderers associated, which are responsible to render the mesh, or in other words, send the mesh data (vertex positions, texture coordinates, normals etc...) to opengl. These renderers are child objects of the mesh (since both the mesh and the renderer objects are inherited from TreeNode) They are used in different circumstances, for example mudbox uses one renderer for plain rendering, and another one for wireframe rendering. These renderer object can hold cached buffers in memory, to be able to render the mesh as fast as possible. The reason why mudbox keeps multiple renderers and not uses a single one to render the mesh in different modes is that this way the renderers can hold precalculated data in buffers. A naiv implementation of this interface would go through all the faces in the mesh, and pump the mesh data with immediate opengl calls to the hardware, but of course this solution would be slow for most of the objects.


Public Member Functions

virtual const mudbox::ClassDesc RuntimeClass (void) const
virtual void  Initialize (void)
  This function is called when the plugin first used. This is responsible for one time initialization.
virtual void  SetMesh (Mesh *pMesh)
  Called to set the mesh for the renderer node. Usually called only once right after the creation of a node. Each mesh has its own renderer nodes so dont expect this function to be called often.
virtual void  Render (const Selector *pSelector=0, bool bSkipMaterials=false, const Camera *pCamera=0, const AxisAlignedBoundingBox &bUVFilter=AxisAlignedBoundingBox())
  Render the mesh to the current framebuffer with the current pipeline settings.
virtual unsigned int  RenderData (const Selector *pSelector, unsigned int iStart, const Camera *pCamera)
  This function is responsible to render some data into the framebuffer, which later should tell the exact vertex index of one of the corners of the current face. The rendered value have to be greater or equal to iStart. The function have to return the lowest value not used by the funtion (That value will be used as iStart for further RenderData() calls). See also VertexIndexFromData().
virtual void  DecodeData (unsigned int iData, unsigned int &iFaceIndex, unsigned int &iVertexIndex)
  This function have to calculate the vertex or face index from the value rendered by RenderData(). If a value is unknown it must be set to 0xffffffff.
virtual void  OnVertexPositionChange (unsigned int iVertexIndex, unsigned int iFaceIndex)
  Called when any vertex of the associated mesh is changed its position.
virtual void  OnVertexStateChange (unsigned int iVertexIndex, unsigned int iFaceIndex)
  Called when any vertex of the associated mesh is changed its state.
virtual void  OnMeshChange (void)
  Called when the mesh changed in any way, like changed the number of vertices or faces.
virtual void  SetLODLevel (float fLevel)
  Set the level of detail for the renderer.
virtual float  LODLevel (void) const
  Returns the level of detail for the renderer.
virtual const AxisAlignedBoundingBox ActiveUVArea (void) const
  Returns the currently rendered UV tile.
virtual void  SetWireFrameMode (bool bMode)
  Set wireframe status. If set to true, the surface will be rendered as wireframe.
virtual bool  WireFrameMode (void) const
  Returns true if wireframe is on.
virtual void  SetColorMode (bool bMode)
  Set the color mode. If set to true, colors for each vertex will be passed to the pipeline based on the status of the vertex.
virtual bool  ColorMode (void) const
  Returns true if the renderer currently contains color information.
virtual void  SetWireLevel (unsigned int iLevel)
  Set the subdivision level for the wireframe display. Zero means the base level.
virtual unsigned int  WireLevel (void) const
  Returns the current wire level.
virtual void  SetTextureCoordinateMode (bool bMode)
  Set the texture coordinate mode. If true, the texture coordinates will be passed to the opengl pipeline.
virtual bool  TextureCoordinateMode (void) const
  Returns true if the renderer contains texture coordinates.
virtual void  SetTangentMode (bool bMode)
  Set the tangent mode. If true, tangents and binormals will be also passed to the pipeline.
virtual bool  TangentMode (void) const
  Returns true if the renderer contains tangents.
virtual bool  ReadyForClientRender ()
virtual void  SetFacetedMode (bool bMode)
  Set the faceted mode. If true, shading will use face normal, otherwise it will use vertex normal.
virtual bool  FacetedMode (void) const
  Returns if faceted mode is on.

Static Public Member Functions

const mudbox::ClassDesc StaticClass (void)
mudbox::Node CreateInstances (unsigned int iCount=1)

Member Function Documentation

virtual const mudbox::ClassDesc* mudbox::MeshRenderer::RuntimeClass void   )  const [inline, virtual]
 

Reimplemented from mudbox::TreeNode.

00093 { return true;}
const mudbox::ClassDesc* mudbox::MeshRenderer::StaticClass void   )  [static]
 

Reimplemented from mudbox::TreeNode.

mudbox::Node* mudbox::MeshRenderer::CreateInstances unsigned int  iCount = 1  )  [static]
 

Reimplemented from mudbox::TreeNode.

virtual void mudbox::MeshRenderer::Initialize void   )  [virtual]
 

This function is called when the plugin first used. This is responsible for one time initialization.

Reimplemented from mudbox::Node.

virtual void mudbox::MeshRenderer::SetMesh Mesh pMesh  )  [virtual]
 

Called to set the mesh for the renderer node. Usually called only once right after the creation of a node. Each mesh has its own renderer nodes so dont expect this function to be called often.

virtual void mudbox::MeshRenderer::Render const Selector pSelector = 0,
bool  bSkipMaterials = false,
const Camera pCamera = 0,
const AxisAlignedBoundingBox bUVFilter = AxisAlignedBoundingBox()
[virtual]
 

Render the mesh to the current framebuffer with the current pipeline settings.

This is the main function of the class, this will do the job. The pipeline is already set up for accepting the mesh data, so this function should leave all opengl states untouched.

Parameters:
bSkipMaterials  This is a pointer to a selector object (for example a camera frustum selector), or can be NULL. When this pointer is specified, the renderer object should filter the data and only render those parts which are selected by the selector node. The renderer can ignore this parameter, but for the best performance it is recommended to use it. See class Selector for more details.
pCamera  When this parameter is true, the renderer should ignore the material data stored for the mesh. This parameter will be removed from future releases.
bUVFilter  This pointer specifies which camera will be used during the rendering. Only those faces should be rendered whose texture coordinates are inside this bounding box, the others should be ignored.
virtual unsigned int mudbox::MeshRenderer::RenderData const Selector pSelector,
unsigned int  iStart,
const Camera pCamera
[virtual]
 

This function is responsible to render some data into the framebuffer, which later should tell the exact vertex index of one of the corners of the current face. The rendered value have to be greater or equal to iStart. The function have to return the lowest value not used by the funtion (That value will be used as iStart for further RenderData() calls). See also VertexIndexFromData().

virtual void mudbox::MeshRenderer::DecodeData unsigned int  iData,
unsigned int &  iFaceIndex,
unsigned int &  iVertexIndex
[virtual]
 

This function have to calculate the vertex or face index from the value rendered by RenderData(). If a value is unknown it must be set to 0xffffffff.

virtual void mudbox::MeshRenderer::OnVertexPositionChange unsigned int  iVertexIndex,
unsigned int  iFaceIndex
[virtual]
 

Called when any vertex of the associated mesh is changed its position.

virtual void mudbox::MeshRenderer::OnVertexStateChange unsigned int  iVertexIndex,
unsigned int  iFaceIndex
[virtual]
 

Called when any vertex of the associated mesh is changed its state.

virtual void mudbox::MeshRenderer::OnMeshChange void   )  [virtual]
 

Called when the mesh changed in any way, like changed the number of vertices or faces.

virtual void mudbox::MeshRenderer::SetLODLevel float  fLevel  )  [virtual]
 

Set the level of detail for the renderer.

virtual float mudbox::MeshRenderer::LODLevel void   )  const [virtual]
 

Returns the level of detail for the renderer.

virtual const AxisAlignedBoundingBox& mudbox::MeshRenderer::ActiveUVArea void   )  const [virtual]
 

Returns the currently rendered UV tile.

virtual void mudbox::MeshRenderer::SetWireFrameMode bool  bMode  )  [virtual]
 

Set wireframe status. If set to true, the surface will be rendered as wireframe.

virtual bool mudbox::MeshRenderer::WireFrameMode void   )  const [virtual]
 

Returns true if wireframe is on.

virtual void mudbox::MeshRenderer::SetColorMode bool  bMode  )  [virtual]
 

Set the color mode. If set to true, colors for each vertex will be passed to the pipeline based on the status of the vertex.

virtual bool mudbox::MeshRenderer::ColorMode void   )  const [virtual]
 

Returns true if the renderer currently contains color information.

virtual void mudbox::MeshRenderer::SetWireLevel unsigned int  iLevel  )  [virtual]
 

Set the subdivision level for the wireframe display. Zero means the base level.

virtual unsigned int mudbox::MeshRenderer::WireLevel void   )  const [virtual]
 

Returns the current wire level.

virtual void mudbox::MeshRenderer::SetTextureCoordinateMode bool  bMode  )  [virtual]
 

Set the texture coordinate mode. If true, the texture coordinates will be passed to the opengl pipeline.

virtual bool mudbox::MeshRenderer::TextureCoordinateMode void   )  const [virtual]
 

Returns true if the renderer contains texture coordinates.

virtual void mudbox::MeshRenderer::SetTangentMode bool  bMode  )  [virtual]
 

Set the tangent mode. If true, tangents and binormals will be also passed to the pipeline.

virtual bool mudbox::MeshRenderer::TangentMode void   )  const [virtual]
 

Returns true if the renderer contains tangents.

virtual bool mudbox::MeshRenderer::ReadyForClientRender  )  [inline, virtual]
 
00093 { return true;}
virtual void mudbox::MeshRenderer::SetFacetedMode bool  bMode  )  [virtual]
 

Set the faceted mode. If true, shading will use face normal, otherwise it will use vertex normal.

virtual bool mudbox::MeshRenderer::FacetedMode void   )  const [virtual]
 

Returns if faceted mode is on.


mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer
mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer mudbox::MeshRenderer